//书写品牌管理模块接口
import request from '@/utils/request'
import type { TColumnListResponseData, TColumn } from './type'
enum API {
  //获取已有品牌接口
  URL_COLUMN_LIST = '/v1/m/column/allColumns',
  // //添加品牌
  URL_COLUMN_ADD = '/v1/m/column',
  URL_COLUMN_UPDATE = '/v1/m/column/',

  //删除已有品牌
  URL_COLUMN_DELETE = '/v1/m/column/',
}

export const reqColumnList = (
  pageNum: number,
  pageSize: number,
  columnTitle: string,
) =>
  request.get<any, TColumnListResponseData>(
    API.URL_COLUMN_LIST +
      `?page=${pageNum}&pageSize=${pageSize}&columnTitle=${columnTitle}`,
  )
// //添加与修改已有品牌接口方法
export const reqAddOrUpdateColumn = (data: TColumn) => {
  if (data.columnId) {
    return request.put<any, any>(API.URL_COLUMN_UPDATE + data.columnId, data)
  } else {
    return request.post<any, any>(API.URL_COLUMN_ADD, data)
  }
}

export const reqDeleteColumn = (id: string) =>
  request.delete<any, any>(API.URL_COLUMN_DELETE + id)
